package com.yyl.fmall.user.exception;

import com.yyl.fmall.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @BelongsProject: rbacs
 * @BelongsPackage: com.yyl.rbacs.exception
 * @Author: YuanSir
 * @CreateTime: 2022-11-01  15:33
 * @Description:
 * @Version: 1.0
 */

@RestControllerAdvice
public class GlobalExceptionHandler {
    
    
    @ExceptionHandler(IllegalCharacterException.class)
    public R illegalCharacterExceptionHandler(IllegalCharacterException exception){
    
        exception.printStackTrace();
        return R.error(exception.getMsg());
    
    }
    
    @ExceptionHandler(Exception.class)
    public R exceptionHandler(Exception exception){
        
        exception.printStackTrace();
        return R.error(exception.getMessage());
        
    }
    
    @ExceptionHandler(Throwable.class)
    public R throwableHandler(Throwable throwable){
        
        throwable.printStackTrace();
        return R.error(throwable.getMessage());
    
    }
}
